<?php
$menus = array(
    "users.php" => "Users",
    "avatars.php" => "Avatars",
    "emoticons.php" => "Emoticons",
    "themes.php" => "Themes"
);

?>
<ul id="adminMenu">
<?php if(ServiceFactory::get("AuthenticationService") -> CurrentUserCan()) { ?>
<li><a href='index.php' class="<?php if($currentFile == "index.php") echo "Current" ?>">Thông tin</a></li>
<?php
}

$man = false;

// User không thể access trang này
if(ServiceFactory::get("AuthenticationService") -> CurrentUserCan())
{
    foreach ($menus as $key => $v)
    {
        if($currentFile == $key)
        {
            $class="Current";
            $man = true;
            break;
        }
    }
    echo "<li><a href='users.php' class='$class'>Quản lý</a></li>";
}

?>
</ul>
<ul id="sideMenu">
<li><a href='profile.php' class="<?php if($currentFile=="profile.php") echo "Current" ?>">Tài khoản</a></li>
<?php if(ServiceFactory::get("AuthenticationService") -> isSuperAdministrator(ServiceFactory::get("AuthenticationService") -> getCurrentUser())) { ?>
<li><a href='general.php' class="<?php if($currentFile=="general.php") echo "Current" ?>">Cấu hình</a></li>
<?php } ?>
</ul>
<ul id="subMenu">
<?php
if(ServiceFactory::get("AuthenticationService") -> CurrentUserCan()) {
    if($man)
    {
        $class = "";
        if($currentFile == "users.php")
            $class = "Current";

        if(ServiceFactory::get("AuthenticationService") -> isManager(ServiceFactory::get("AuthenticationService") -> getCurrentUser()))
            echo "<li><a href='users.php' class=\"$class\">Users</a></li>";
        else
        {
            foreach ($menus as $key => $value)
            {
                $class = "";
                if($currentFile == $key)
                    $class = "Current";
                
                echo "<li><a href=\"$key\" class=\"$class\">$value</a></li>";
            }
        }
    }
}
?>
</ul>
<div id="body">
    <div class="Wrap">